#include "path_api.h"

void JOUI::Jo_UIPath_Create(LPVOID& dst)
{
	dst = new UIPath();
}

HRESULT JOUI::Jo_UIPath_LineTo(LPVOID hPath, float x1, float y1, float x2, float y2)
{
	auto fPath = (UIPath*)hPath;
	if (fPath)
		return fPath->LineTo(x1, y1, x2, y2);
	return S_FALSE;
}

HRESULT JOUI::Jo_UIPath_AddRect(LPVOID hPath, float left, float top, float right, float bottom)
{
	auto fPath = (UIPath*)hPath;
	if (fPath)
		return fPath->AddRect(left, top, right, bottom);
	return S_FALSE;
}

HRESULT JOUI::Jo_UIPath_AddRoundRect(LPVOID hPath, float left, float top, float right, float bottom, float radius)
{
	auto fPath = (UIPath*)hPath;
	if (fPath)
		return fPath->AddRoundRect(left, top, right, bottom, radius);
	return S_FALSE;
}

HRESULT JOUI::Jo_UIPath_AddCustomRoundRect(LPVOID hPath, float left, float top, float right, float bottom, float radius_left_top, float radius_right_top, float radius_right_bottom, float radius_left_bottom)
{
	auto fPath = (UIPath*)hPath;
	if (fPath)
		return fPath->AddCustomRoundRect(left, top, right, bottom, radius_left_top, radius_right_top, radius_right_bottom, radius_left_bottom);
	return S_FALSE;
}

HRESULT JOUI::Jo_UIPath_AddArc(LPVOID hPath, float x1, float y1, float x2, float y2, float radiusX, float radiusY, bool fClockwise)
{
	auto fPath = (UIPath*)hPath;
	if (fPath)
		return fPath->Arc(x1, y1, x2, y2, radiusX, radiusY, fClockwise);
	return S_FALSE;
}

HRESULT JOUI::Jo_UIPath_BeginPath(LPVOID hPath, bool winding_mode)
{
	auto fPath = (UIPath*)hPath;
	if (fPath)
		return fPath->BeginPath(winding_mode);
	return S_FALSE;
}

HRESULT JOUI::Jo_UIPath_EndPath(LPVOID hPath)
{
	auto fPath = (UIPath*)hPath;
	if (fPath)
		return fPath->EndPath();
	return S_FALSE;
}

HRESULT JOUI::Jo_UIPath_StartFigure(LPVOID hPath, float x, float y)
{
	auto fPath = (UIPath*)hPath;
	if (fPath)
		return fPath->StartFigure(x, y);
	return S_FALSE;
}

HRESULT JOUI::Jo_UIPath_FinishFigure(LPVOID hPath, bool close_figure)
{
	auto fPath = (UIPath*)hPath;
	if (fPath)
		return fPath->FinishFigure(close_figure);
	return S_FALSE;
}

void JOUI::Jo_UIPath_Destroy(LPVOID hPath)
{
	auto fPath = (UIPath*)hPath;
	if (fPath)
		delete fPath;
}

HRESULT JOUI::Jo_UIPath_Reset(LPVOID hPath)
{
	auto fPath = (UIPath*)hPath;
	if (fPath)
		return fPath->Reset();
	return S_FALSE;
}
